package com.maiji.cloud.entities.community;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.maiji.cloud.entities.login.UserInfo;
import com.maiji.cloud.response.community.ComMsgBaseOutputDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@NoArgsConstructor
@Data
@Accessors(chain=true)
@Table(name = "com_middle_user_message")

public class ComMiddleUserMessage {

    @Column(name = "message_id", type = MySqlTypeConstant.VARCHAR, length = 50, isKey = true)
    private String messageId;

    @Column(name = "source_user_id", type = MySqlTypeConstant.VARCHAR, length = 50)
    private String sourceUserId;

    @Column(name = "target_user_id", type = MySqlTypeConstant.VARCHAR, length = 50)
    private String targetUserId;

    @Column(name = "msg_id", type = MySqlTypeConstant.VARCHAR, length = 50)
    private String msgId; //动态ID

    @Column(name = "cur_comment_id", type = MySqlTypeConstant.VARCHAR, length = 50)
    private String curCommentId; //当前评论ID

    @Column(name = "last_comment_id", type = MySqlTypeConstant.VARCHAR, length = 50)
    private String lastCommentId; //上一条评论ID

    @Column(name = "content", type = MySqlTypeConstant.VARCHAR, length = 1024)
    private String content;

    @Column(name = "is_read",type = MySqlTypeConstant.INT,length = 2,defaultValue = "0")
    private Integer isRead;// 是否已读 0:否 1:是

    @Column(name = "type",type = MySqlTypeConstant.INT,length = 2)
    private Integer type; //  0:评论 1:收到的赞 2:新粉丝（关注） 3:回复记录 4:@ 5：评论的评论

    @Column(name = "create_time", type = MySqlTypeConstant.BIGINT)
    private Long createTime;//创建时间戳



    @ApiModelProperty("来源用户")
    @TableField(exist = false)
    private UserInfo sourceUser;

    @ApiModelProperty("动态信息")
    @TableField(exist = false)
    private ComMsgBaseOutputDto msg;

    @ApiModelProperty("动态归属人")
    @TableField(exist = false)
    private UserInfo userOfMsg;

    @TableField(exist = false)
    private String puchContent;

    public String getPuchContent() {
        if(type == 0){
            return "评论了你的动态";
        }else if(type == 1){
            return "赞了你的动态";
        }else if(type == 2){
            return "关注了你";
        }else if(type == 3){
            return "回复了你";
        }else if(type == 4){
            return "@了你";
        }else if(type == 5){
            return "评论了你的评论";
        }
        return "😊";
    }
}
